﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DynamicChart.Data;

namespace Sinochem.TMS.LogisticChartService
{
    public class AgingQuery : IChartDataQuery
    {
        public ChartData GetData(DateRange dateRange, QueryParameter parameter)
        {
            ChartData chart = new ChartData
            {
                Type = ChartType.Pie
            };

            if (dateRange.Mode == "y")
            {
                chart.Caption = string.Format("库存商库龄分析（{0}年）",
                    dateRange.CurrentDate.Year);
            }
            else
            {
                chart.Caption = string.Format("库存商库龄分析（{0}年{1}月）",
                    dateRange.CurrentDate.Year,
                    dateRange.CurrentDate.Month);
            }

            ChartSeriesData seriesData = new ChartSeriesData();
            chart.SeriesData.Add(seriesData);
            seriesData.Caption = "结构";

            seriesData.Items.Add(new ChartDataItem
            {
                Name = "0-3月",
                Color = "#66C2FF",
                Value = new Random().Next(2210, 3300),
                NavigationUrl = string.Empty
            });
            seriesData.Items.Add(new ChartDataItem
            {
                Name = "3-8月",
                Color = "#77BB77",
                Value = new Random().Next(140, 4020),
                NavigationUrl = string.Empty
            });
            seriesData.Items.Add(new ChartDataItem
            {
                Name = "8-2年",
                Color="#EEDC82",
                Value = new Random().Next(1240, 6020),
                NavigationUrl = string.Empty
            });
            seriesData.Items.Add(new ChartDataItem
            {
                Name = "2年以上",
                Color = "#EE6363",
                Value = new Random().Next(5240, 8020),
                NavigationUrl = string.Empty
            });

            return chart;
        }
    }
}
